Skip to content

soundwire: intel: don't mask all status changes, only the detected ones - #3439

Closed
plbossart wants to merge 1 commit into
thesofproject:topic/sof-devfrom
plbossart:fix/sdw-interrupt-masks
Closed

plbossart wants to merge 1 commit into
thesofproject:topic/sof-devfrom
plbossart:fix/sdw-interrupt-masks

Conversation

@plbossart

Copy link
Copy Markdown
Member

On a status change, we mask all possible sources of
interrupts (ATTACH, ALERT and UNATTACHED).

This may not be so clever, for example when a device becomes
UNATTACHED we will mask the ATTACH interrupt. If a device re-attaches
immediately while we are processing the interrupt and workqueue, we
may never detect attachment.

FIXME: we've got to get rid of the set of 'if' tests.

BugLink: #3063
Signed-off-by: Pierre-Louis Bossart pierre-louis.bossart@linux.intel.com

On a status change, we mask all possible sources of
interrupts (ATTACH, ALERT and UNATTACHED).

This may not be so clever, for example when a device becomes
UNATTACHED we will mask the ATTACH interrupt. If a device re-attaches
immediately while we are processing the interrupt and workqueue, we
may never detect attachment.

FIXME: we've got to get rid of the set of 'if' tests.

BugLink: thesofproject#3063
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>

slv_mask = cdns_readl(cdns, CDNS_MCP_INTMASK);

/* FIXME: there must be a clever way to do this in one shot */

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

slv_mask &= ~(int_status & CNDS_MCP_INT_SLAVE_MASK); ?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure if it's equivalent but I wrote this down:

slv_mask &= (~int_status & CNDS_MCP_INT_SLAVE_MASK);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not equal. Your method will only reserve the bit in range of CNDS_MCP_INT_SLAVE_MASK, for other no-slave int status will lost

@RanderWang RanderWang left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a amazing idea !

@plbossart

Copy link
Copy Markdown
Member Author

After sleeping on it and lots of coffee, I am not convinced this actually works.

a) the work function willl enable all interrupts

cdns_updatel(cdns, CDNS_MCP_INTMASK,
CDNS_MCP_INT_SLAVE_MASK, CDNS_MCP_INT_SLAVE_MASK);

so there's a risk that dealing with one status change would override the masking done in a new interrupt.

b) the documentation states that all interrupt handling is level-based.

I still think there's a risk in the case of multiple devices on the same link, e.g.

  1. deviceA attaches as device0

  2. we handle the interrupt

  3. the workqueue starts, we read the status
    slave0 = cdns_readl(cdns, CDNS_MCP_SLAVE_INTSTAT0);
    slave1 = cdns_readl(cdns, CDNS_MCP_SLAVE_INTSTAT1);

  4. we deal with the status change and program deviceA dev_num

  5. deviceB attaches as device0, the status will not change

  6. we clear the status bits for the slave -> we will never detect deviceB!

@plbossart plbossart closed this Feb 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants